{smcl}
{com}{sf}{ul off}{txt}{.-}
      name:  {res}<unnamed>
       {txt}log:  {res}C:\Users\murdie\Dropbox\ISA 2023 Naz Victor Abortion\Conditional Acceptance Stage 2024\Replication Data for A Ticking Time Bomb\Log File of Replication Do File for A Ticking Time Bomb - To Make Maps in Manuscript.smcl
  {txt}log type:  {res}smcl
 {txt}opened on:  {res}17 May 2024, 13:30:28

{com}. do "C:\Users\murdie\Dropbox\ISA 2023 Naz Victor Abortion\Conditional Acceptance Stage 2024\Replication Data for A Ticking Time Bomb\Replication Do File for A Ticking Time Bomb - To Make Maps in Manuscript.do"
{txt}
{com}. ***Replication Do File for "A Ticking Time Bomb: Restrictions on Abortion Rights and Physical Integrity Rights"
. *Nazli Avdan, Amanda Murdie, and Victor Asal"
. *Date: 5/16/2024
. *Please reach out to murdie@uga.edu with any questions 
. 
. 
. **This folder just replicates the maps shown in the manuscript
. 
. clear 
{txt}
{com}. *remember to set your working directory to where the replication dataset is 
. cd "C:\Users\murdie\Dropbox\ISA 2023 Naz Victor Abortion\Conditional Acceptance Stage 2024\Replication Data for A Ticking Time Bomb"
{res}C:\Users\murdie\Dropbox\ISA 2023 Naz Victor Abortion\Conditional Acceptance Stage 2024\Replication Data for A Ticking Time Bomb
{txt}
{com}. 
. use ReplicationDataset.dta, replace
{txt}
{com}. tsset ccode year 
{res}
{col 1}{txt:Panel variable: }{res:ccode}{txt: (unbalanced)}
{p 1 16 2}{txt:Time variable: }{res:year}{txt:, }{res:{bind:1946}}{txt: to }{res:{bind:2023}}{txt:, but with gaps}{p_end}
{txt}{col 10}Delta: {res}1 unit
{txt}
{com}. 
. 
. keep ccode year cai_cai1 cai_cai2 BackwardsAbortioncai1 BackwardsAbortioncai2 Largerthanorequal2dropcai1 Largerthan2SDdropcai2 
{txt}
{com}. 
. 
. gen backslidingall = BackwardsAbortioncai1  + BackwardsAbortioncai2 +  Largerthanorequal2dropcai1 + Largerthan2SDdropcai2 
{txt}(11,577 missing values generated)

{com}. 
. by ccode: egen totalbacksliding = sum(backslidingall)
{txt}
{com}. by ccode: egen meancai1 = mean(cai_cai1)
{txt}(1,062 missing values generated)

{com}. by ccode: egen meancai2 = mean(cai_cai2)
{txt}(1,062 missing values generated)

{com}. by ccode: egen totalBackwardsAbortioncai1 = sum(BackwardsAbortioncai1)
{txt}
{com}. by ccode: egen totalBackwardsAbortioncai2 = sum(BackwardsAbortioncai2)
{txt}
{com}. 
. 
. 
. keep if year==2015
{txt}(15,676 observations deleted)

{com}. 
. keep if totalbacksliding!=.
{txt}(0 observations deleted)

{com}. 
. 
.                 ssc install kountry, replace
{txt}checking {hilite:kountry} consistency and verifying not already installed...
all files already exist and are up to date.

{com}.                 kountry ccode, from(cown) to(iso3n)

{txt}{hline 44}
You are converting from {com}cown{txt} to {com}iso3n{txt}....
{hline 44}

{hline 38}
The command has finished.
The new variable is named {com}_ISO3N_{txt}.
{hline 38}

{com}.                 rename _ISO3N iso3n
{res}{txt}
{com}.         kountry ccode, from(cown)

{txt}{hline 40}
The command has finished.
The new variable is named {com}NAMES_STD{txt}.
{hline 40}

{com}.         replace iso3n = 643 if NAMES_STD=="Russia"
{txt}(1 real change made)

{com}.         replace iso3n = 729 if NAMES_STD=="Sudan"
{txt}(1 real change made)

{com}. 
.                 drop if iso3n==.
{txt}(8 observations deleted)

{com}.                 sort iso3n
{txt}
{com}. save map.dta, replace 
{txt}{p 0 4 2}
file {bf}
map.dta{rm}
saved
{p_end}

{com}. 
. 
.                 *2. Now, get shapefiles that are at the correct (country) level and change those into Stata files 
. 
.                 *There are lots of great places to download free shapefiles online, I use: https://www.naturalearthdata.com/, I used these files https://www.naturalearthdata.com/downloads/10m-cultural-vectors/  
. 
.                 *set your working directory to where those unzipped shape files are
. 
.                 cd "C:\Users\murdie\Dropbox\ISA 2023 Naz Victor Abortion\Conditional Acceptance Stage 2024\Replication Data for A Ticking Time Bomb\ne_10m_admin_0_countries"
{res}C:\Users\murdie\Dropbox\ISA 2023 Naz Victor Abortion\Conditional Acceptance Stage 2024\Replication Data for A Ticking Time Bomb\ne_10m_admin_0_countries
{txt}
{com}. 
.                 *3: Have Stata change your shapefiles into Stata data files
.                 
.                 ssc install shp2dta, replace
{txt}checking {hilite:shp2dta} consistency and verifying not already installed...
all files already exist and are up to date.

{com}.                 
.                 shp2dta using ne_10m_admin_0_countries, data(worlddata) coor(worldcoor) genid(id)
{res}type: 5
{txt}
{com}.                 
.                 *this will create two files - a worlddata.dta file and a worldcoor.dta file from the .dbf and .shp shapefiles in that folder you downloaded 
. 
.                 *let's take a look at the data real quick, just so you know what these coordinate and attribute files look like
.                 
.                 *coordinates (this is what gives the lines and shapes to draw the map)
.                 use worldcoor.dta, clear
{txt}
{com}.                 browse
{txt}
{com}.                 
.                 *attribute file (this is what we'll want to merge the happiness data with)
.                 *we need to find (or create) the variable that we will merge on (this would be the ISO 3-numeric codes)
.                 *we must relabel this as ccode (like we had in our pressfreedom dataset)
.                 use worlddata.dta, clear
{txt}
{com}.                 browse
{txt}
{com}. 
.                 rename ISO_N3 iso3n
{res}{txt}
{com}.                 *make sure it is a numeric variable
.                 destring iso3n, replace
{txt}iso3n: all characters numeric; {res}replaced {txt}as {res}int
{txt}
{com}.                 save "worlddata.dta", replace
{txt}{p 0 4 2}
file {bf}
worlddata.dta{rm}
saved
{p_end}

{com}. 
.                 sort iso3n
{txt}
{com}. 
.                 *4: merge the attribute data you are intested in working with: merge one to one on ccodes 
.                 *set working directory back to the class folder
.                 use worlddata.dta, clear
{txt}
{com}.                 sort iso3n
{txt}
{com}. 
.                 cd "C:\Users\murdie\Dropbox\ISA 2023 Naz Victor Abortion\Conditional Acceptance Stage 2024\Replication Data for A Ticking Time Bomb"
{res}C:\Users\murdie\Dropbox\ISA 2023 Naz Victor Abortion\Conditional Acceptance Stage 2024\Replication Data for A Ticking Time Bomb
{txt}
{com}.                 *merge
.                 merge iso3n using "map.dta"
{txt}{p}
(you are using old
{bf:merge} syntax; see
{bf:{help merge:[D] merge}} for new syntax)
{p_end}
{p 0 4 2}
variable{txt} iso3n
does not uniquely identify observations in
the master data
{p_end}

{com}.                 *now, reset the working directory back to the shapefile folder 
.                 cd "C:\Users\murdie\Dropbox\ISA 2023 Naz Victor Abortion\Conditional Acceptance Stage 2024\Replication Data for A Ticking Time Bomb\ne_10m_admin_0_countries"
{res}C:\Users\murdie\Dropbox\ISA 2023 Naz Victor Abortion\Conditional Acceptance Stage 2024\Replication Data for A Ticking Time Bomb\ne_10m_admin_0_countries
{txt}
{com}. 
.                 *5: draw map, the id is the code in the shapefiles that connects the coordinates to the attributes 
. 
.                 *first, you can easily draw a blank map
.                 spmap using "worldcoor.dta", id(id)
{res}{txt}
{com}.                 
.                 *heat map, quartiles are the default 
.                 spmap meancai1 using  "worldcoor.dta", id(id) fcolor(Reds) 
{res}{txt}
{com}. 
.  
. *colorblind friendly colors
. colorpalette viridis, n(11) nograph reverse
{res}{txt}
{com}. 
. local colors `r(p)'
{txt}
{com}. * fcolor("`colors'") *
. 
. spmap meancai2 using  "worldcoor.dta" if ADMIN!="Antarctica", id(id) fcolor("`colors'") clmethod(custom) clbreaks(0 .1 .2 .3  .4  .5 .6 .7 .8 .9 1) 
{res}{txt}
{com}. 
.                 
. colorpalette viridis, n(6) nograph reverse
{res}{txt}
{com}. 
. local colors `r(p)'     
{txt}
{com}. spmap totalBackwardsAbortioncai2 using  "worldcoor.dta" if ADMIN!="Antarctica", id(id) fcolor("`colors'")  clmethod(custom) clbreaks(0 1 2 3 4 5 ) 
{res}{txt}
{com}. 
.                 
.                 *There are more than 15 Color palettes for color blindness from Martin Krzywinski and et al.
. 
. *See also GETTING INTO VISUALIZATION OF LARGE BIOLOGICAL DATA SETS and "Controversial Color Use on Maps"(Brewer, 1997).
. *https://cran.r-project.org/web/packages/colorBlindness/vignettes/colorBlindness.html
.                 spmap meancai2 using  "worldcoor.dta" if ADMIN!="Antarctica", id(id) fcolor(Paired)  clmethod(custom) clbreaks(0 .1 .2 .3  .4  .5 .6 .7 .8 .9 1) 
{res}{txt}
{com}.                 
.                 spmap totalBackwardsAbortioncai2 using  "worldcoor.dta" if ADMIN!="Antarctica", id(id) fcolor(Paired)  clmethod(custom) clbreaks(0 1 2 3 4 5 ) 
{res}{txt}
{com}.                                 
. 
. 
. 
{txt}end of do-file

{com}. log close
      {txt}name:  {res}<unnamed>
       {txt}log:  {res}C:\Users\murdie\Dropbox\ISA 2023 Naz Victor Abortion\Conditional Acceptance Stage 2024\Replication Data for A Ticking Time Bomb\Log File of Replication Do File for A Ticking Time Bomb - To Make Maps in Manuscript.smcl
  {txt}log type:  {res}smcl
 {txt}closed on:  {res}17 May 2024, 13:30:56
{txt}{.-}
{smcl}
{txt}{sf}{ul off}